home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / SCALE < prev    next >
Encoding:
Text File  |  1985-12-14  |  1.3 KB  |  44 lines

  1. ;-------------------------scale routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page :173
  4. ; NAME SCALE
  5. ; ROUTINE FOR LINEAR SCALING
  6. ;
  7. ; FUNCTION: This routine performs a linear scaling, converting a fixed
  8. ; point number between 0 and 1 to an integer between X1 and X2, where
  9. ; X1 and X2 are 16-bit integers.
  10. ; INPUT: Upon entry CX has a binary fixed point number between 0 and
  11. ; 1.  The binary point is to the left of the leftmost bit.  X1 and X2 are
  12. ; variables stored in memory.
  13. ; OUTPUT: Upon exit CX contains the 16-bit integer result.
  14. ; REGISTERS USED:  Only CX is modified.
  15. ; SEGMENTS REFERENCED:  The data segment must contain the variables X1
  16. ; and X2.
  17. ; ROUTINES CALLED:  None
  18. ; SPECIAL NOTES: None
  19. ;
  20. ; ROUTINE TO SCALE LINEARLY
  21. ;
  22. scale    proc    far
  23. ;
  24.     push    dx        ; save registers
  25.     push    ax
  26. ;
  27. ; compute width
  28.     mov    ax,x2        ; get x2
  29.     sub    ax,x1        ; subtract x1
  30. ;
  31. ; multiply width by input parameter
  32.     mul    cx        ; multiply
  33.     mov    cx,dx        ; move top part of quotient into CX
  34. ;
  35. ; add lower limit
  36.     add    cx,x1        ; add x1
  37. ;
  38.     pop    dx        ; restore registers
  39.     pop    dx
  40.     ret            ; return
  41. ;
  42. scale    endp
  43. ;-------------------------scale routine ends---------------------------+
  44.